<script setup>
import { ref, useTemplateRef, onMounted } from 'vue'

const list = ref([
  'a',
  'b',
  'c',
])

const itemRefs = useTemplateRef('items')
/* 获取模板引用属性 */
const input = useTemplateRef('my-input')


onMounted(() => {
  console.log(itemRefs.value)
  input.value.focus()
})
</script>

<template>

  <ul>
    获取模板引用属性 便于初始化聚焦(focus) my-input: <input ref="my-input" />
  </ul>

  <ul>
    v-for-item: <li v-for="item in list" ref="items">
      {{ item }}
    </li>
  </ul>
</template>